﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Reflection;
using System.Diagnostics;

using System.IO;
using System.Runtime.Serialization;
using System.Xml.Serialization;

using GeneralLib;
using GeneralDefine;
using System.ComponentModel;


namespace IOModule
{
    [XmlInclude(typeof(IOInputItem))]
    public class IOInputItem
    {
        public string strName;
        public int iChannal;
        public bool bReverse;
        public bool bIgnore;
        public string strRemark;

        [XmlIgnore]
        private IInput actioner;
        //[XmlIgnore]
        //private bool bON;
        //[XmlIgnore]
        //private bool bOff;

        public IOInputItem()
        {
            strName = "";
            strRemark = "";
            iChannal = 0;

        }
        public void RefreshActioner()
        {
            actioner = (IInput)FrameManager.FrameManager.MotionCard;

        }
        [XmlIgnore, Browsable(false)]
        public bool ON
        {
            get
            {
                bool bResult = false;
                if (bIgnore)
                {
                    return true;
                }
                if (actioner == null)
                {
                    return false;
                }
                if (bReverse)
                {
                    bResult = !actioner.GetInput(iChannal);
                }
                else
                {
                    bResult = actioner.GetInput(iChannal);
                }
                return bResult;
            }
        }
        [XmlIgnore, Browsable(false)]
        public bool OFF
        {
            get
            {
                bool bResult = false;
                if (bIgnore)
                {
                    return true;
                }
                if (actioner == null)
                {
                    return false;
                }
                if (bReverse)
                {
                    bResult = actioner.GetInput(iChannal);
                }
                else
                {
                    bResult = !actioner.GetInput(iChannal);
                }

                return bResult;
            }
        }
        public string Name
        {
            get { return strName; }
            set { strName = value; }
        }
        public int Channal
        {
            get { return iChannal; }
            set { iChannal = value; }
        }
        public bool Reverse
        {
            get { return bReverse; }
            set { bReverse = value; }
        }
        public bool Ignore
        {
            get { return bIgnore; }
            set { bIgnore = value; }
        }

        public string Remark
        {
            get { return strRemark; }
            set { strRemark = value; }
        }
    }
}
